package com.select.course.controller;

import com.select.course.service.SchoolCollegeService;
import com.select.course.utils.PageUtils;
import com.select.course.utils.R;
import com.select.course.vo.AllVo;
import com.select.course.vo.CollegeVo;
import com.select.course.vo.PageVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
@CrossOrigin
@RestController
@RequestMapping("/college")
public class SchoolCollegeController {
    @Resource
    private SchoolCollegeService schoolCollegeService;

    @PostMapping("/addcollege")
    public R addCollege(@RequestBody AllVo allVo) {
        schoolCollegeService.addCollege(allVo);

        return R.ok();
    }

    @PutMapping("/updatecollege")
    public R updateCollege(@RequestBody AllVo allVo) {
        schoolCollegeService.updateCollege(allVo);
        return R.ok();
    }
    @GetMapping("/getcollegeinfo/{id}")
    public R getCollegeInfo(@PathVariable Long id) {
        CollegeVo collegeVo = schoolCollegeService.getCollegeInfo(id);
        return R.ok().put("data",collegeVo);
    }
    @DeleteMapping("/deletecollege/{id}")
    public R deleteCollege(@PathVariable Long id) {
        schoolCollegeService.deleteCollege(id);
        return R.ok();
    }


    //getcollegegroup
    @GetMapping("getcollegegroup")
    public R getCollegeGroup() {
        List<CollegeVo> collegeVos = schoolCollegeService.getCollegeGroup();

        return R.ok().put("data",collegeVos);
    }

    //getallcollege
    @PostMapping("/getallcollege")
    public R getAllCollege(@RequestBody PageVo pageVo) {
        PageUtils pageUtils = schoolCollegeService.getAllCollege(pageVo);
        return R.ok().put("data",pageUtils);
    }
}
